package main

import (
	"fmt"
	"time"
)

func main() {
	key := ""
	loop := true

	//余额
	balance := 10000.0
	//每次收支的money
	money := 0.0
	//收支说明
	note := ""
	details := "收支\t账户金额\t收支金额\t说   明"
	for {
		fmt.Println("------------------------家庭收支记账软件------------------------")
		fmt.Println("\t\t\t\t\t\t  1.收支明细")
		fmt.Println("\t\t\t\t\t\t  2.登记收入")
		fmt.Println("\t\t\t\t\t\t  3.登记支出")
		fmt.Println("\t\t\t\t\t\t  4.退   出")
		fmt.Println("\t\t\t\t\t\t    请选择（1-4）\n\n\n")
		fmt.Scanln(&key)
		switch key {
		case "1":
			fmt.Println("------------------------当前收支明细记录------------------------")
			fmt.Println(details)
			fmt.Printf("账户余额=%f\n收支明细=%f\n收支说明=%s\n", balance, money, note)
			fmt.Println(details)
			time.Sleep(time.Millisecond * 1000)
		case "2":
			fmt.Println("请输入本次收入：")
			fmt.Scanln(&money)
			fmt.Println("请输入收入说明：")
			fmt.Scanln(&note)
			balance += money
			details += fmt.Sprintf(note)
		case "3":
			fmt.Println("请输入本次支出：")
			fmt.Scanln(&money)
			fmt.Println("请输入支出说明：")
			fmt.Scanln(&note)
			balance -= money
		case "4":
			loop = false
		default:
			fmt.Println("请输入正确的选项")
		}

		if !loop {
			break
		}
	}
	fmt.Println("你退出家庭收支记账软件成功")

}
